package com.zengqingfa.springboot.validation.demo.controller;

import com.zengqingfa.springboot.validation.demo.entity.UserDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


@RestController
@RequestMapping("/user3")
@Slf4j
public class UserRest3 {

    @PostMapping("/create")
    public String saveUser2(@RequestBody @Validated(UserDto.Save.class) UserDto user) {
        log.info("user:{}", user);
        return "save success2";
    }

    @PostMapping("/update")
    public String updateUser(@RequestBody @Validated(UserDto.Update.class) UserDto user) {
        log.info("user:{}", user);
        return "update success";
    }


}
